package com.smart.admin.utils;

/**
 * @Author xiaoqiang
 * @Version Result.java, v 0.1 2025年03月18日 14:55 xiaoqiang
 * @Description: TODO
 */
public class Result <T>{
    private String msg;

    private String code;

    private T data;

    private boolean success;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public boolean getSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    private Result(){

    }
    public static <T> Result<T> success(T data){
        Result<T> result = new Result<T>();
        result.setSuccess(true);
        result.setData(data);
        return result;

    }

    public static <T> Result<T> fail(String code,String msg){
        Result<T> result = new Result<T>();
        result.setSuccess(false);
        result.setMsg(msg);
        result.setCode(code);
        return result;
    }
}
